package com.nintendo.controller;

import com.nintendo.result.GraceJSONResult;
import com.nintendo.service.FileService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@RestController
@RequestMapping("/files")
@Slf4j
public class FileController {
    @Autowired
    private FileService fileService;
    @PostMapping("/generateQrCode")
    public String generateQrCode(@RequestParam("userId")String userId,
                                 @RequestParam("wechatNum")String wechatNum){
        String qrCodeUrl = fileService.generateQrCode(userId,wechatNum);
        return qrCodeUrl;
    }
    @PostMapping("/uploadImage")
    public String uploadImage(@RequestParam("file")MultipartFile file){
        String url = fileService.uploadImage(file);
        return url;
    }
    /**
     * 多文件上传
     */
    @PostMapping("/multUploadImage")
    public List<String> multUploadImage(@RequestParam("file")MultipartFile[] files){
        List<String> images = fileService.multUploadImage(files);
        return images;
    }
}
